package com.opennews.openplatform.myspringbootcore.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;
import java.time.LocalDateTime;

public class LocalDateTimeToUTCSerializer extends StdSerializer<LocalDateTime> {
    public LocalDateTimeToUTCSerializer() {
        super(LocalDateTime.class);
    }

    @Override
    public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        String formatted = DateHelper.convertLocalDateTimeToUTCString(value);
        gen.writeString(formatted);
    }
}

